package org.jeecg.modules.demo.jxcx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.demo.jxcx.Utils.R;
import org.jeecg.modules.demo.jxcx.mapper.JxcCzrzMapper;
import org.jeecg.modules.demo.jxcx.po.JxcCzrz;
import org.jeecg.modules.demo.jxcx.service.JxcCzrzService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
* @author Administrator
* @description 针对表【jxc_czrz】的数据库操作Service实现
* @createDate 2024-09-03 13:07:23
*/
@Service
public class JxcCzrzServiceImpl extends ServiceImpl<JxcCzrzMapper, JxcCzrz>
implements JxcCzrzService{

    @Override
    public R add(JxcCzrz jxcCzrz) {
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        String formattedDateTime = now.format(formatter);
        if (StringUtils.isBlank(jxcCzrz.getCreatTime())){
            jxcCzrz.setCreatTime(formattedDateTime);
        }
        return new R().ok(save(jxcCzrz));
    }

    @Override
    public List<JxcCzrz> queryczrz(String companyId) {
        return baseMapper.queryczrz(companyId);
    }

    @Override
    public JxcCzrz getByIdAndOther(String id, String otherid, String companyId) {
        return baseMapper.getByIdAndOther(id, otherid, companyId);
    }
}
